/******************************************************************************
  XYXKC_Motor.cpp
  xiaoyingxing expansion board mind module
  Creation Date: 10-25-2023
  @ XYXKC

  Supports offline speech recognition with four motor drives

  Distributed as-is; no warranty is given.
******************************************************************************/
#include"XYXKC_Motor.h"
#include "Arduino.h"
#include<math.h>

XYXKC_Motor::XYXKC_Motor(bool isEsp32E) {
    if(isEsp32E){
        uint8_t M3[2] = {23,25};//p15 p9
    } else{
        uint8_t M3[2] = {21,25};//p15 p9
    }
}



/**
 * @brief 电机运行
 * @param MotorTab 电机
 * @param speed 速度
 * */
void XYXKC_Motor::motorRun(uint8_t *MotorTab, int speed) {
    int speedAbs = abs(speed) > 100 ? 100 : abs(speed);
    if (speed > 0) {
        analogWrite(MotorTab[0], 0);
        analogWrite(MotorTab[1], speedAbs * 10.23);
    } else {
        analogWrite(MotorTab[1], 0);
        analogWrite(MotorTab[0], speedAbs * 10.23);
    }

}



